/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package personal.xml;

import javax.xml.bind.ValidationEvent;
import javax.xml.bind.ValidationEventHandler;
import javax.xml.bind.ValidationEventLocator;

/**
 *
 * @author PHATNBSE61057
 */
public class JAXBBookValidationHandler implements ValidationEventHandler {

    @Override
    public boolean handleEvent(ValidationEvent event) {
        if (event.getSeverity() == ValidationEvent.FATAL_ERROR || event.getSeverity() == ValidationEvent.ERROR) {
            ValidationEventLocator locator = event.getLocator();
            //Print message from validation event
            System.out.println("Invalid booking document: " + locator.getURL());
            System.out.println("Error: " + event.getMessage());
            System.out.println("Error at column " + locator.getColumnNumber() + ", line " + locator.getLineNumber());

        }
        return true;
    }
}
